﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DelegateConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            //GreetingDelegate delegate1, delegate2;

            //delegate1 = EnglishGreet;
            //delegate2 = ChineseGreet;

            //GreetPeopleForDelegate("Liker", delegate1);
            //GreetPeopleForDelegate("李志中", delegate2);

            //GreetingManager gm = new GreetingManager();
            //gm.GreetPeople("Liker", EnglishGreet);
            //gm.GreetPeople("李志中", ChineseGreet);

            //GreetingManager gm = new GreetingManager();
            //gm.MakeGreet += EnglishGreet;
            //gm.MakeGreet += ChineseGreet;

            //gm.GreetPeople("Liker");

            //Console.ReadLine();

            //Heater ht = new Heater();
            //ht.BoilWater();

            HeaterObserver hearob = new HeaterObserver();
            Alarm alarm = new Alarm();
            Display display = new Display();

            hearob.BoilEvent += alarm.MakeAlert;
            hearob.BoilEvent += display.ShowMsg;

            hearob.BoilWater();

            Console.ReadKey();
        }

        public enum Language
        {
            English,
            Chinese
        }

        //public delegate void GreetingDelegate(string name);

        public static void GreetPeopleForDelegate(string name, GreetingDelegate MakeGreeting)
        {
            MakeGreeting(name);
        }
            

        public void GreetPeople(string name,Language lang)
        {
            switch(lang)
            {
                case Language.English:
                    EnglishGreet(name);
                    break;
                case Language.Chinese:
                    ChineseGreet(name);
                    break;
            }
            
        }

        public static void EnglishGreet(string name)
        {
            Console.WriteLine("Good Morning," + name);
        }

        public static void ChineseGreet(string name)
        {
            Console.WriteLine("早上好," + name);
        }


        
    }
}
